package com.publishproject.test;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.ListView;

import com.publishproject.R;
import com.ui_componet.looppic.CycleViewPager;
import com.ui_componet.looppic.bean.LoopImageModel;

import java.util.ArrayList;

import pushlish.tang.com.commonutils.ToastUtils;

public class LoopPicActivity extends Activity {

    private String [] images = {
            "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1794894692,1423685501&fm=116&gp=0.jpg",
            "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3771287340,4264471813&fm=116&gp=0.jpg",
            "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1303680113,133301350&fm=116&gp=0.jpg",
            "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1350614941,725003865&fm=116&gp=0.jpg"
    };
    private CycleViewPager cycleViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loop_pic);
        cycleViewPager = (CycleViewPager)findViewById(R.id.loop_view);

        CycleViewPager.Configuration configuration = new CycleViewPager.Configuration()
                .activity(this)
                .cycle(true)
                .gravity(Gravity.CENTER_HORIZONTAL);
        cycleViewPager.setConfiguration(configuration);
        cycleViewPager.setData(createObj(), new CycleViewPager.ImageCycleViewListener() {
            @Override
            public void onImageClick(LoopImageModel info, int postion, View imageView) {
                Log.i("TAG","打印信息"+info.getLoopImageUrl()+"--"+postion);
            }
        });

    }

    private ArrayList<LoopObj> createObj() {
        ArrayList<LoopObj> imageModels = new ArrayList<>();
        imageModels.add(new LoopObj(images[0]));
        imageModels.add(new LoopObj(images[1]));
        imageModels.add(new LoopObj(images[2]));
        imageModels.add(new LoopObj(images[3]));
        return imageModels;

    }
}
